
Partial Class ScheduleMatch
    Inherits System.Web.UI.Page

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        ' we don't want to show the edit and delete buttons for fixtures in the past
        Dim SelectedDate As DateTime = DateTime.Parse(GridView1.SelectedRow.Cells(2).Text)
        Dim fixtureInFuture As Boolean = (SelectedDate >= DateTime.Now)

        DetailsView1.AutoGenerateEditButton = fixtureInFuture
        DetailsView1.AutoGenerateDeleteButton = fixtureInFuture

    End Sub

    Sub DetailsView1_ItemDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewDeletedEventArgs)
        GridView1.DataBind()
        DetailsView1.DataBind()
    End Sub

    Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
        GridView1.DataBind()
        DetailsView1.DataBind()
    End Sub

    Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
        GridView1.DataBind()
        DetailsView1.DataBind()
    End Sub

    Protected Sub NewMatch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewMatch.Click
        DetailsView1.ChangeMode(DetailsViewMode.Insert)
    End Sub
End Class
